# Contributor: Leo <thinkabit.ukim@gmail.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=taglib
pkgver=1.13.1
pkgrel=0
pkgdesc="Library for reading and editing metadata of several popular audio formats"
url="https://taglib.github.io/"
arch="all"
license="LGPL-2.1-only OR MPL-1.1"
makedepends="zlib-dev cmake samurai"
checkdepends="cppunit-dev"
subpackages="
	$pkgname-dev
	libtag:_lib
	libtag_c:_lib
	"
source="https://taglib.github.io/releases/taglib-$pkgver.tar.gz"

# secfixes:
#   1.11.1-r2:
#     - CVE-2017-12678
#     - CVE-2018-11439

build() {
	CFLAGS="$CFLAGS -flto=auto" \
	CXXFLAGS="$CXXFLAGS -flto=auto" \
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DWITH_ZLIB=ON \
		-DBUILD_SHARED_LIBS=ON \
		-DBUILD_EXAMPLES=ON \
		-DBUILD_TESTING="$(want_check && echo ON || echo OFF)" \
		-DVISIBILITY_HIDDEN=ON
	cmake --build build
}

check() {
	ctest --test-dir build --output-on-failure
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

_lib() {
	pkgdesc="$pkgdesc ($subpkgname lib)"

	amove usr/lib/$subpkgname.so.*
}

sha512sums="
986231ee62caa975afead7e94630d58acaac25a38bc33d4493d51bd635d79336e81bba60586d7355ebc0670e31f28d32da3ecceaf33292e4bc240c64bf00f35b  taglib-1.13.1.tar.gz
"
